<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>Document</title>
    <script src="node_modules/react/umd/react.development.js"></script>
    <script src="node_modules/react-dom//umd/react-dom.development.js"></script>
    <script src="node_modules/babel-standalone/babel.min.js"></script>
  </head>
  <body>
    <!-- 创建dom 根节点 -->

    <div id="demoReact"></div>

    <script type="text/babel">
      //jsx
      // let text = '你好'
      // let myDom = <h1>{text}</h1>

      //修改样式
      // let mStyle = {color:"red"}
      // let myDom = <p style={mStyle}>修改我的样式</p>

      //列表渲染  map()

      let arr = ["吃饭", "睡觉", "打豆豆"];
        let index2 = 0;
      function fun() {
        
        let myDom = arr.map((item, index) => {
          return (
            <p
              style={{ color: index == index2 ? "red" : "" }}
              key={index}
              onClick={() => {
                index2 = index;
                render();
                console.log(index,index2);
              }}
            >
              {item}
            </p>
          );
        });
        return myDom
      }

      function render() {
        ReactDOM.render(fun(), document.getElementById("demoReact"));
      }
      render();
    </script>
  </body>
</html>
